package com.fourhats.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.springframework.stereotype.Repository;

import com.fourhats.dao.PostDAO;
import com.fourhats.model.Post;

@Repository
public class PostDAOImpl extends GenericDAOImpl<Post, Long> implements PostDAO {

	protected PostDAOImpl() {
		super(Post.class.getName());
	}

	@SuppressWarnings("unchecked")
	public List<Post> getAllOrderByDate() {
		DetachedCriteria criteria = DetachedCriteria.forEntityName(entityName);
		criteria.addOrder(Order.desc("creationDate"));
        return getHibernateTemplate().findByCriteria(criteria);
	}
}